home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / backup / dds2tar-.000 / dds2tar-2.4.12.tar / dds2tar-2.4.12 / tar-1.11.8.patch < prev    next >
Text File  |  1996-02-05  |  13KB  |  459 lines

  1. diff -ru tar-1.11.8/src/buffer.c tar-1.11.8.1/src/buffer.c
  2. --- tar-1.11.8/src/buffer.c    Mon May 29 02:26:27 1995
  3. +++ tar-1.11.8.1/src/buffer.c    Mon Feb  5 20:20:19 1996
  4. @@ -46,6 +46,7 @@
  5.  /* Where we write messages (standard messages, not errors) to.  Stdout
  6.     unless we're writing a pipe, in which case stderr.  */
  7.  FILE *stdlis;
  8. +FILE *stdrec;
  9.  
  10.  #define    STDIN    0        /* standard input  file descriptor */
  11.  #define    STDOUT    1        /* standard output file descriptor */
  12. @@ -77,7 +78,7 @@
  13.  static int childpid = 0;
  14.  
  15.  /* Record number of the start of this block of records  */
  16. -long baserec;
  17. +long baserec = 0 ;
  18.  
  19.  /* Error recovery stuff  */
  20.  static int r_error_count;
  21. @@ -520,11 +521,64 @@
  22.  void
  23.  open_archive (int reading)
  24.  {
  25. -  stdlis = flag_exstdout ? stderr : stdout;
  26. +  time_t start_time = time(0) ;
  27. +  stdrec = stdlis = flag_exstdout ? stderr : stdout;
  28. +  if ( record_file_name != NULL )
  29. +    {
  30. +#define INSERT_TIMESTAMP
  31. +#ifdef INSERT_TIMESTAMP
  32. +      /*
  33. +       * A record-file name with '%T' will be expanded with a decimal
  34. +       * value for the timestamp of the archive. This is the time value
  35. +       * stored in the label record.
  36. +       * If you are using only one computer, this should be a unique number.
  37. +       * You are able to create different rec-files for all your archives,
  38. +       * as well as finding the index of your archive in a reliable way.
  39. +       *
  40. +       * Another way would be to let us set the timestamp by another option.
  41. +       * tar --timestamp <ts-number> ...
  42. +       */
  43. +      char rfn[256];
  44. +      if ( reading == 0 ) {
  45. +        char*p= record_file_name ;
  46. +        int i = 0 ;
  47. +        int n;
  48. +        while ( p[0] != '\0' ) {
  49. +          if ( p[0] == '%' && p[1] == 'T' ) {
  50. +            /* i += */ sprintf(rfn+i,"%d",start_time);
  51. +            i = strlen(rfn) ;
  52. +            p += 2 ;
  53. +          } else { rfn[i++] = *p++ ; }
  54. +        }
  55. +        rfn[i] = '\0' ;
  56. +      } else strcpy(rfn,record_file_name);
  57. +#else
  58. +      char*rfn=record_file_name;
  59. +#endif
  60. +      if ( ( stdrec = fopen(rfn,"w")) == NULL )
  61. +        {
  62. +          fprintf(stdlis,"Cannot open %s.\n",record_file_name);
  63. +          exit(1);
  64. +        }
  65. +    }
  66. +
  67.  
  68.    if (blocksize == 0)
  69.      ERROR ((TAREXIT_FAILURE, 0, _("Invalid value for blocksize")));
  70.  
  71. +  if ( ( flag_sayblock ) && ( flag_volhdr ) )
  72. +    {
  73. +      fprintf(stdrec,
  74. +        "loc             timestamp is %d \n",
  75. +        start_time);
  76. +    }
  77. +  if ( flag_sayblock && (blocksize != 10240) )
  78. +    {
  79. +      fprintf(stdrec,
  80. +        "loc             block length is %d bytes = %d * 512 bytes \n",
  81. +        blocksize,blocksize>>9);
  82. +    }
  83. +
  84.    if (archive_names == 0)
  85.      ERROR ((TAREXIT_FAILURE, 0,
  86.          _("No archive name given, what should I do?")));
  87. @@ -618,6 +672,38 @@
  88.    setmode (archive, O_BINARY);
  89.  #endif
  90.  
  91. +#if defined(MTIOCGET)
  92. +  /* Prints the file number of the archive */
  93. +  if ( flag_sayblock )
  94. +    {
  95. +      struct mtget get ;
  96. +      int i ;
  97. +      i = ioctl(archive,MTIOCGET,&get);
  98. +      if (( i == 0 ) && ( get.mt_fileno >= 0 ))
  99. +        {
  100. +          fprintf(stdrec,
  101. +            "loc             number of the file is %d \n",
  102. +            get.mt_fileno );
  103. +        }
  104. +    }
  105. +#endif
  106. +
  107. +#if defined(MTIOCPOS)
  108. +  /* Prints the tape block number on every Linux SCSI-device */
  109. +  if ( flag_sayblock )
  110. +    {
  111. +      struct mtpos pos ;
  112. +      int i ;
  113. +      i = ioctl(archive,MTIOCPOS,&pos);
  114. +      if ( i == 0 )
  115. +        {
  116. +          fprintf(stdrec,
  117. +            "loc             number of the first block is %d\n",
  118. +            pos.mt_blkno );
  119. +        }
  120. +    }
  121. +#endif
  122. +
  123.    if (reading)
  124.      {
  125.        ar_last = ar_block;    /* set up for 1st block = # 0 */
  126. @@ -666,7 +752,7 @@
  127.        assign_string (¤t_file_name, ar_block->header.arch_name);
  128.  
  129.        ar_block->header.linkflag = LF_VOLHDR;
  130. -      to_oct (time (0), 1 + 12, ar_block->header.mtime);
  131. +      to_oct (start_time , 1 + 12, ar_block->header.mtime);
  132.        finish_header (ar_block);
  133.  #if 0
  134.        ar_record++;
  135. @@ -727,7 +813,7 @@
  136.    if (err != blocksize && !flag_multivol)
  137.      writeerror (err);
  138.    else if (flag_totals)
  139. -    tot_written += blocksize;
  140. +    tot_written += blocking;
  141.  
  142.    if (err > 0)
  143.      bytes_written += err;
  144. @@ -816,7 +902,7 @@
  145.    if (err != blocksize)
  146.      writeerror (err);
  147.    else if (flag_totals)
  148. -    tot_written += blocksize;
  149. +    tot_written += blocking;
  150.  
  151.  
  152.    bytes_written = blocksize;
  153. diff -ru tar-1.11.8/src/create.c tar-1.11.8.1/src/create.c
  154. --- tar-1.11.8/src/create.c    Sat Jun 17 23:08:13 1995
  155. +++ tar-1.11.8.1/src/create.c    Thu Feb  1 18:30:26 1996
  156. @@ -315,7 +315,10 @@
  157.    to_oct ((long) sum, 8, header->header.chksum);
  158.    header->header.chksum[6] = '\0';    /* zap the space */
  159.  
  160. -  userec (header);
  161. +  /* print header first to get the same output with 'tar -tvR'
  162. +   * and 'tar -cvR'
  163. +   */
  164. +  /* userec (header); */
  165.  
  166.    if (flag_verbose)
  167.      {
  168. @@ -327,6 +330,8 @@
  169.        head_standard = flag_standard;
  170.        print_header ();
  171.      }
  172. +
  173. +  userec (header) ;
  174.  
  175.    return;
  176.  }
  177. diff -ru tar-1.11.8/src/list.c tar-1.11.8.1/src/list.c
  178. --- tar-1.11.8/src/list.c    Wed May  3 05:28:17 1995
  179. +++ tar-1.11.8.1/src/list.c    Thu Feb  1 18:30:26 1996
  180. @@ -200,7 +200,7 @@
  181.        if (written > size)
  182.          written = size;
  183.        errno = 0;
  184. -      check = fwrite (data, sizeof (char), written, stdlis);
  185. +      check = fwrite (data, sizeof (char), written, stdrec);
  186.        userec ((union record *) (data + written - 1));
  187.        if (check != written)
  188.          {
  189. @@ -213,8 +213,8 @@
  190.        if (flag_multivol)
  191.      assign_string (&save_name, NULL);
  192.        saverec (NULL);        /* unsave it */
  193. -      fputc ('\n', stdlis);
  194. -      fflush (stdlis);
  195. +      fputc ('\n', stdrec);
  196. +      fflush (stdrec);
  197.        return;
  198.  
  199.      }
  200. @@ -533,9 +533,9 @@
  201.    char *name;
  202.  
  203.    if (flag_sayblock)
  204. -    fprintf (stdlis, _("rec %10ld: "), baserec + (ar_record - ar_block));
  205. +    fprintf (stdrec, _("rec %10ld: "), baserec + (ar_record - ar_block));
  206.  #if 0
  207. -  annofile (stdlis, (char *) NULL);
  208. +  annofile (stdrec, (char *) NULL);
  209.  #endif
  210.  
  211.    if (flag_verbose <= 1)
  212. @@ -547,11 +547,11 @@
  213.  
  214.        if (quoted_name)
  215.      {
  216. -      fprintf (stdlis, "%s\n", quoted_name);
  217. +      fprintf (stdrec, "%s\n", quoted_name);
  218.        free (quoted_name);
  219.      }
  220.        else
  221. -    fprintf (stdlis, "%s\n", current_file_name);
  222. +    fprintf (stdrec, "%s\n", current_file_name);
  223.      }
  224.    else
  225.      {
  226. @@ -562,6 +562,11 @@
  227.        switch (head->header.linkflag)
  228.      {
  229.      case LF_VOLHDR:
  230. +          /* dirty bug fix to display the header processing
  231. +           * tar cvvf /dev/null --label 'hello world' blah...
  232. +           * J"org Weule weule@cs.uni-duesseldorf.de
  233. +           */
  234. +          hstat.st_mtime = from_oct(1 + 12 , head->header.mtime);
  235.        modes[0] = 'V';
  236.        break;
  237.  
  238. @@ -663,18 +668,18 @@
  239.        if (pad > ugswidth)
  240.      ugswidth = pad;
  241.  
  242. -      fprintf (stdlis, "%s %s/%s %*s%s %s %s",
  243. +      fprintf (stdrec, "%s %s/%s %*s%s %s %s",
  244.             modes, user, group, ugswidth - pad, "",
  245.             size, timestamp + 4, timestamp + 20);
  246.  
  247.        name = quote_copy_string (current_file_name);
  248.        if (name)
  249.      {
  250. -      fprintf (stdlis, " %s", name);
  251. +      fprintf (stdrec, " %s", name);
  252.        free (name);
  253.      }
  254.        else
  255. -    fprintf (stdlis, " %s", current_file_name);
  256. +    fprintf (stdrec, " %s", current_file_name);
  257.  
  258.        switch (head->header.linkflag)
  259.      {
  260. @@ -682,26 +687,26 @@
  261.        name = quote_copy_string (current_link_name);
  262.        if (name)
  263.          {
  264. -          fprintf (stdlis, " -> %s\n", name);
  265. +          fprintf (stdrec, " -> %s\n", name);
  266.            free (name);
  267.          }
  268.        else
  269. -        fprintf (stdlis, " -> %s\n", current_link_name);
  270. +        fprintf (stdrec, " -> %s\n", current_link_name);
  271.        break;
  272.  
  273.      case LF_LINK:
  274.        name = quote_copy_string (current_link_name);
  275.        if (name)
  276.          {
  277. -          fprintf (stdlis, _(" link to %s\n"), name);
  278. +          fprintf (stdrec, _(" link to %s\n"), name);
  279.            free (name);
  280.          }
  281.        else
  282. -        fprintf (stdlis, _(" link to %s\n"), current_link_name);
  283. +        fprintf (stdrec, _(" link to %s\n"), current_link_name);
  284.        break;
  285.  
  286.      default:
  287. -      fprintf (stdlis, _(" unknown file type `%c'\n"),
  288. +      fprintf (stdrec, _(" unknown file type `%c'\n"),
  289.             head->header.linkflag);
  290.        break;
  291.  
  292. @@ -714,24 +719,24 @@
  293.      case LF_FIFO:
  294.      case LF_CONTIG:
  295.      case LF_DUMPDIR:
  296. -      putc ('\n', stdlis);
  297. +      putc ('\n', stdrec);
  298.        break;
  299.  
  300.      case LF_VOLHDR:
  301. -      fprintf (stdlis, _("--Volume Header--\n"));
  302. +      fprintf (stdrec, _("--Volume Header--\n"));
  303.        break;
  304.  
  305.      case LF_MULTIVOL:
  306. -      fprintf (stdlis, _("--Continued at byte %ld--\n"),
  307. +      fprintf (stdrec, _("--Continued at byte %ld--\n"),
  308.             from_oct (1 + 12, head->header.offset));
  309.        break;
  310.  
  311.      case LF_NAMES:
  312. -      fprintf (stdlis, _("--Mangled file names--\n"));
  313. +      fprintf (stdrec, _("--Mangled file names--\n"));
  314.        break;
  315.      }
  316.      }
  317. -  fflush (stdlis);
  318. +  fflush (stdrec);
  319.  }
  320.  
  321.  /*--------------------------------------------------------------.
  322. @@ -753,9 +758,9 @@
  323.        demode ((unsigned) mode, modes + 1);
  324.  
  325.        if (flag_sayblock)
  326. -    fprintf (stdlis, _("rec %10ld: "), baserec + (ar_record - ar_block));
  327. +    fprintf (stdrec, _("rec %10ld: "), baserec + (ar_record - ar_block));
  328.  #if 0
  329. -      annofile (stdlis, (char *) NULL);
  330. +      annofile (stdrec, (char *) NULL);
  331.  #endif
  332.        name = quote_copy_string (pathname);
  333.        if (!name)
  334. diff -ru tar-1.11.8/src/tar.c tar-1.11.8.1/src/tar.c
  335. --- tar-1.11.8/src/tar.c    Sat Jun 17 22:48:32 1995
  336. +++ tar-1.11.8.1/src/tar.c    Mon Feb  5 21:03:41 1996
  337. @@ -860,6 +860,7 @@
  338.  #define OPTION_VOLNO_FILE    15
  339.  #define OPTION_COMPRESS_PROG    16
  340.  #define OPTION_RSH_COMMAND    17
  341. +#define OPTION_RECORD_FILE      18
  342.  
  343.  /* Some cleanup is made in GNU tar long options.  Using old names will send
  344.     a warning to stderr.  */
  345. @@ -925,6 +926,7 @@
  346.    {"preserve-permissions", no_argument, NULL, 'p'},
  347.    {"read-full-blocks", no_argument, NULL, 'B'},
  348.    {"record-number", no_argument, NULL, 'R'},
  349. +  {"record-file", required_argument, NULL, OPTION_RECORD_FILE},
  350.    {"remove-files", no_argument, &flag_remove_files, 1},
  351.    {"rsh-command", required_argument, NULL, OPTION_RSH_COMMAND},
  352.    {"same-order", no_argument, NULL, 's'},
  353. @@ -1059,6 +1061,7 @@
  354.        --checkpoint      print directory names while reading the archive\n\
  355.        --totals          print total bytes written while creating archive\n\
  356.    -R, --record-number   show record number within archive with each message\n\
  357. +      --record-file     print the record information to file, enable -R\n\
  358.    -w, --interactive     ask for confirmation for every action\n\
  359.        --confirmation    same as -w\n"),
  360.           stdout);
  361. @@ -1212,6 +1215,11 @@
  362.      flag_rsh_command = optarg;
  363.      break;
  364.  
  365. +      case OPTION_RECORD_FILE:
  366. +        record_file_name = optarg ;
  367. +        flag_sayblock++;         /* Print block #s for debug */
  368. +        break;
  369. +
  370.        case 'g':
  371.      /* We are making a GNU dump; save directories at the beginning
  372.         of the archive, and include in each directory its contents.  */
  373. @@ -1626,9 +1634,42 @@
  374.        break;
  375.  
  376.      case COMMAND_CREATE:
  377. +/*
  378. + * Comment the next line out if you have problems. Joerg Weule
  379. + */
  380. +#define PRINT_TROUPUT
  381. +#ifdef PRINT_TROUPUT
  382. +      start_time = time(0);
  383. +      create_archive ();
  384. +      if (flag_totals) {
  385. +    time_t end_time = time(0);
  386. +    double sec = end_time - start_time ;
  387. +    double t = ((double)tot_written) * RECORDSIZE ;
  388. +    fprintf (stderr, _("Total bytes written: %.0f"),t);
  389. +    if ( t >= 1e9 ) fprintf(stderr, " (%3.1f Gb)",t/1e9 ); else
  390. +    if ( t >= 1e6 ) fprintf(stderr, " (%3.1f Mb)",t/1e6 ); else
  391. +    if ( t >= 1024 ) fprintf(stderr, " (%3.1f Kb)",t/1024 );
  392. +    fprintf(stderr,"\n");
  393. +    if ( sec > 0.1 ){
  394. +      long s, m, h = sec ;
  395. +          m = h ;
  396. +      h /= 3600 ;
  397. +          m -= h * 3600 ;
  398. +          s = m ;
  399. +          m /= 60 ;
  400. +          s -= m / 60 ;
  401. +      fprintf (stderr, _("Elapsed time: %02d:%02d:%02d, %g sec\n"), h,m,s,sec);
  402. +      if ( !flag_multivol)
  403. +        fprintf (stderr, _("Throughput per second: %.0fKb/sec\n"),
  404. +          t/sec/1024);
  405. +    }
  406. +      }
  407. +#else
  408.        create_archive ();
  409.        if (flag_totals)
  410. -    fprintf (stderr, _("Total bytes written: %d\n"), tot_written);
  411. +    fprintf (stderr, _("Total bytes written: %g\n")),
  412. +          ((double)tot_written) * RECORDSIZE );
  413. +#endif
  414.        break;
  415.  
  416.      case COMMAND_EXTRACT:
  417. diff -ru tar-1.11.8/src/tar.h tar-1.11.8.1/src/tar.h
  418. --- tar-1.11.8/src/tar.h    Sat Jun 17 20:36:49 1995
  419. +++ tar-1.11.8.1/src/tar.h    Mon Feb  5 20:19:19 1996
  420. @@ -183,6 +183,9 @@
  421.      int numbytes;
  422.    };
  423.  
  424. +/* Time of writing.  */
  425. +GLOBAL time_t start_time;
  426. +
  427.  /* Start of block of archive.  */
  428.  GLOBAL union record *ar_block;
  429.  
  430. @@ -207,6 +210,9 @@
  431.  /* File containing names to work on.  */
  432.  GLOBAL const char *namefile_name;
  433.  
  434. +/* File to write record information to. */
  435. +GLOBAL char *record_file_name;
  436. +
  437.  /* \n or \0.  */
  438.  GLOBAL char filename_terminator;
  439.  
  440. @@ -219,8 +225,8 @@
  441.  /* Initial size of the sparsearray.  */
  442.  GLOBAL int sp_array_size;
  443.  
  444. -/* Total written to output.  */
  445. -GLOBAL int tot_written;
  446. +/* Total written to output in records.  */
  447. +GLOBAL long int tot_written;
  448.  
  449.  /* Compiled regex for extract label.  */
  450.  GLOBAL struct re_pattern_buffer *label_pattern;
  451. @@ -338,6 +344,7 @@
  452.  
  453.  extern long baserec;
  454.  extern FILE *stdlis;
  455. +extern FILE *stdrec;
  456.  extern char *save_name;
  457.  extern long save_sizeleft;
  458.  extern long save_totsize;
  459.